package com.qf.mywatch.view;

import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.qf.mywatch.R;

import java.util.Timer;
import java.util.TimerTask;

public class WelocmeActivity extends AppCompatActivity {

    private Timer timer;//计时器
    private Handler handler;//处理者
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welocme);
        handler = new Handler(new Handler.Callback() {
            @Override
            public boolean handleMessage(Message msg) {
                startActivity(new Intent(WelocmeActivity.this, MainActivity.class));
                finish();
                return true;
            }
        });
        timer = new Timer();
        //参数说明：1、子线程，2、延迟时间，3、间隔时间
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                handler.sendEmptyMessage(10);
            }
        }, 1000, 2000);
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        timer.cancel();
    }
}
